<?php
session_start();

//Variables de session
$_SESSION['tablePropertiesIdOrder'];//0 Asc 1 Desc
$_SESSION['tablePropertiesIdentificacionOrder'];
$_SESSION['tablePropertiesPrecioOrder'];
$_SESSION['tablePropertiesMonto_ArriendoOrder'];
//-------------------

require("../../../weblinx/weblinx.php");

require("../../Classes/Setter.php");
require("../../Classes/Property.php");

require("../../Forms/Invitados/FrmTableProperties.php");
require("../../Forms/Invitados/FrmPropertiesInfo.php");

if(isset($_POST['masInfo'])){
	$property=new Property();
	$property->cargar($_POST['masInfo']);
	$frmPropertiesInfo=new FrmPropertiesInfo($property);	
	$frmPropertiesInfo->show();
}
else if(isset($_POST['Id'])){
	if($_SESSION['tablePropertiesIdOrder']==0){
		$consult="SELECT id, identificacion, precio, montoArriendo, idZona, idTipo FROM inmuebles ORDER BY id ASC";
		$_SESSION['tablePropertiesIdOrder']=1;
	}
	else{
		$consult="SELECT id, identificacion, precio, montoArriendo, idZona, idTipo FROM inmuebles ORDER BY id DESC";
		$_SESSION['tablePropertiesIdOrder']=0;
	}
	
	$frmTableProperties=new FrmTableProperties();
	$frmTableProperties->setDbConsult($consult);
	$frmTableProperties->show();
	
}
else if(isset($_POST['Identificacion'])){
	if($_SESSION['tablePropertiesIdentificacionOrder']==0){
		$consult="SELECT id, identificacion, precio, montoArriendo, idZona, idTipo FROM inmuebles ORDER BY identificacion ASC";
		$_SESSION['tablePropertiesIdentificacionOrder']=1;
	}
	else{
		$consult="SELECT id, identificacion, precio, montoArriendo, idZona, idTipo FROM inmuebles ORDER BY identificacion DESC";
		$_SESSION['tablePropertiesIdentificacionOrder']=0;
	}
	
	$frmTableProperties=new FrmTableProperties();
	$frmTableProperties->setDbConsult($consult);
	$frmTableProperties->show();
}
else if(isset($_POST['Precio'])){
	if($_SESSION['tablePropertiesPrecioOrder']==0){
		$consult="SELECT id, identificacion, precio, montoArriendo, idZona, idTipo FROM inmuebles ORDER BY precio ASC";
		$_SESSION['tablePropertiesPrecioOrder']=1;
	}
	else{
		$consult="SELECT id, identificacion, precio, montoArriendo, idZona, idTipo FROM inmuebles ORDER BY precio DESC";
		$_SESSION['tablePropertiesPrecioOrder']=0;
	}
	$frmTableProperties=new FrmTableProperties();
	$frmTableProperties->setDbConsult($consult);
	$frmTableProperties->show();
}
else if(isset($_POST['Monto_arriendo_mensual'])){
	if($_SESSION['tablePropertiesMontoArriendoOrder']==0){
		$consult="SELECT id, identificacion, precio, montoArriendo, idZona, idTipo FROM inmuebles ORDER BY montoArriendo ASC";
		$_SESSION['tablePropertiesMontoArriendoOrder']=1;
	}
	else{
		$consult="SELECT id, identificacion, precio, montoArriendo, idZona, idTipo FROM inmuebles ORDER BY montoArriendo DESC";
		$_SESSION['tablePropertiesMontoArriendoOrder']=0;
	}
	$frmTableProperties=new FrmTableProperties();
	$frmTableProperties->setDbConsult($consult);
	$frmTableProperties->show();
	
}
else if(isset($_POST['Zona'])){
	$consult="SELECT id, identificacion, precio, montoArriendo, idZona, idTipo FROM inmuebles";
	$frmTableProperties=new FrmTableProperties();
	$frmTableProperties->setDbConsult($consult);
	$frmTableProperties->show();
	
}
else if(isset($_POST['Tipo'])){
	$consult="SELECT id, identificacion, precio, montoArriendo, idZona, idTipo FROM inmuebles";
	$frmTableProperties=new FrmTableProperties();
	$frmTableProperties->setDbConsult($consult);
	$frmTableProperties->show();
}
?>